<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>VirtualScroll Demo</title>
    <style>
        #app {
            width: 100%;
            height: 80vh;
            border: 1px solid #ccc;
        }
        
        .item {
            padding: 15px;
            border-bottom: 1px solid #eee;
            box-sizing: border-box;
        }
        
        .item:nth-child(odd) {
            background-color: #f9f9f9;
        }
        
        .controls {
            margin: 20px 0;
        }
    </style>
</head>
<body>
    <div id="app"></div>

    <script src="virtual-scroll.js"></script>

    </script>
    <script>
        // 使用示例
        const container = document.getElementById('app');
        const virtualScroll = new DynamicHeightVirtualScroll({
            container,
            itemCount: 10,  // 10000个项目
            estimatedHeight: 50,     // 每个项目50px高
            renderItem: (element, index) => {
                 element.textContent = `Item ${index}`;
  
                // 生成 30 到 100 之间的随机高度
                const randomHeight = 30 + Math.floor(Math.random() * 70);
                element.style.height = `${randomHeight}px`;
                
                element.style.border = '1px solid #ccc';
                element.style.boxSizing = 'border-box';
            }
        });
    </script>
</body>
</html>